<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>个人中心</title>
    <link rel="stylesheet" href="/home/css/reset.css">
    <link rel="stylesheet" href="/home/css/head-footer.css">
    <link rel="stylesheet" href="/home/css/user-center.css">
</head>
<body>
{include file='base/header' /}
<div class="user-center-wrap">
    <div class="user-center">
        <div class="bread-nav">
                <span>
                    <a href="javascript:void(0)">首页 ></a>
                </span>
            <span>
                    <a href="javascript:void(0)">用户中心</a>
                </span>
        </div>
        <div class="user-center-main clearfixa">
            {include file='base/menu' /}


            <div class="user-center-right fr">
                <div class="base-data-list data-list data-list data-list-show">
                    <!-- 所有页面右侧标题 -->
                    <p class="user-center-nav-title">
                        提现管理
                    </p>
                    <div class="cline-data">
                        <!-- table 普通选项卡 -->
                        <div class="table-item-box clearfixa">
                            <!-- 选中的状态 -->
                            <div class="table-item" id="top_one"><a href="{:url('base/withdraw')}">提现记录</a></div>
                            <!-- 未选中的状态 -->
                            <div class="table-item table-item-checked" id="top_two"><a href="{:url('base/apply')}">提现申请</a></div>
                        </div>
                        <div class="base-data-box" id="apply">
                            <form  class="form-left-space">
                                <div class="form-top-space">
                                    <label for="" class="information-nav-title">
                                        当前账户：
                                    </label>

                                    <span><?php echo $arr['user_name'] ?></span>
                                    <input type="hidden" name="proxy_id" value="<?php echo $arr['user_name'] ?>" id="proxy_id">
                                </div>
                                <!-- 账户余额 -->
                                <div class="form-top-space">
                                    <label for="" class="information-nav-title">
                                        账户余额：
                                    </label>
                                    <span class="red-money" id="red_money"><?php echo $arr['bankaccount_balance'] ?></span>
                                    <span class="information-hit">提现不通过的提现申请记录系统会还原该用户的账户余额</span>
                                </div>
                                <div class="form-top-space">
                                    <label for="" class="information-nav-title">
                                        提现金额：
                                    </label>
                                    <input type="text" class="second-inputbox" name="withdraw_amount" id="withdraw_amount">
                                    <span class="red-money">元</span>
                                    <span class="information-hit">可提现金额<?php echo $arr['bankaccount_balance'] ?>元</span>
                                </div>
                                <!-- 无注释大的input框 -->
                                <div class="form-top-space">
                                    <label for="" class="information-nav-title">
                                        <sup>*</sup>添加银行卡：
                                    </label>
                                    <input type="text" class="big-inputbox" name="bank_id" id="bank_id">
                                </div>
                                <!-- 无注释大的input框 -->
                                <div class="form-top-space">
                                    <label for="" class="information-nav-title">
                                        <sup>*</sup>开户银行名称：
                                    </label>
                                    <input type="text" class="big-inputbox" name="bank_name" id="bank_name">
                                </div>
                                <!-- 无注释大的input框 -->
                                <div class="form-top-space">
                                    <label for="" class="information-nav-title">
                                        <sup>*</sup>开户银行户主：
                                    </label>
                                    <input type="text" class="big-inputbox" name="bank_head" id="bank_head">
                                </div>
                                <!-- 居中的提交按钮 -->
                                <input type="button" class="center-btn"  id="button" value="申请提现">

                            </form>
                        </div>

                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
{include file='base/footer' /}
</body>
</html>
<script src="/home/js/jquery-1.11.1.min.js"></script>
<script src="http://libs.baidu.com/jquery/2.1.1/jquery.min.js"></script>
<script src="/home/js/layer-v/layer/layer.js"></script>

<script>

        $(document).on('click','#top_one',function(){

        $(this).removeClass("table-item-checked");

    })

    

    var flag = false;
     
      $(document).on('blur','#withdraw_amount',function()
       {
            var withdraw_amount = $(this).val();
            
            var red_money = $('#red_money').text();
           
            var regwithdraw_amount = /^[0-9]*[1-9][0-9]*$/;

            if(withdraw_amount == "" || withdraw_amount > parseInt(red_money) || !regwithdraw_amount.test(withdraw_amount))
            {
                layer.tips('提现金额必须为小于您的余额 OR 金额不能有小数！', '#withdraw_amount'); 

                flag = false;
            }else
            {
                flag = true;
            }
       })
     $(document).on('blur','#bank_name',function()
       {
            var bank_name = $(this).val();
            
            var regbank_name = /^[\u4e00-\u9fa5]+$/;

            if(bank_name == "" || bank_name.length < 2 || !regbank_name.test(bank_name))
            {
                layer.tips('银行名称必须为中文,不为空！', '#bank_name'); 

                flag = false;
            }else
            {
                flag = true;
            }
       })
      
     $(document).on('blur','#bank_id',function()
       {
            var bank_id = $(this).val();

           var regbank_id = /^\d{19}$/g; 

            if(bank_id == "" || !regbank_id.test(bank_id))
            {
                layer.tips('银行卡号格式不正确！', '#bank_id');

                flag = false;
            }
            else
            {
                flag = true;
            }      
       })
     $(document).on('blur','#bank_head',function()
       {
            var bank_head = $(this).val();
            
            var regbank_head = /^[\u4e00-\u9fa5]+$/;

            if(bank_head == "" || bank_head.length < 2 || !regbank_head.test(bank_head))
            {
                layer.tips('户主必须为中文,不为空！', '#bank_head'); 

                flag = false;
            }else
            {
                flag = true;
            }
       })
   
       $(document).on('click','#button',function(){
            if(flag == false)
            {
                layer.msg('请填写提现信息！', function(){
                //关闭后的操作
                });
                return false;
            }else
            {             
                var proxy_id = $('#proxy_id').val();
                var withdraw_amount = $('#withdraw_amount').val();
                var bank_id = $('#bank_id').val();
                var bank_name = $('#bank_name').val();
                var bank_head = $('#bank_head').val();
                $.ajax({
                    url:"{:url('base/apply')}",
                    data:{
                        proxy_id : proxy_id,
                        withdraw_amount : withdraw_amount,
                        bank_id : bank_id,
                        bank_name : bank_name,
                        bank_head : bank_head
                    },
                    dataType:'json',
                    type:'post',
                    success:function(data)
                    {
                        if(data.code == '1005')
                        {
                              layer.msg('申请已提交', {
                              icon: 16
                              ,shade: 0.01
                            });
                            window.location.href = 'withdraw';
                        }else
                        {
                            window.location.href = 'withdraw';
                        }                      
                    }
                })
            }
        });  
</script>
